package com.boang.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

/*
    @author:sa
    @date:2024/11/29 14:59
*/
public class HashMapDemo {
    public static void main(String[] args) {
//        m1();
        HashMap<Student, String> map = new HashMap<>();
        map.put(new Student("张三",20),"北京");
        map.put(new Student("李四",30),"上海");
        map.put(new Student("王五",50),"广州");
        Set<Student> set = map.keySet();
        Iterator<Student> iterator = set.iterator();
        while (iterator.hasNext()){
            Student key=iterator.next();
            String value= map.get(key);
            System.out.println(key+":"+value);
        }
    }

    private static void m1() {
        HashMap<Student, String> map = new HashMap<>();
        map.put(new Student("张三",20),"北京");
        map.put(new Student("张三",20),"广州");
        map.put(new Student("张三",30),"北京");
        map.remove(new Student("张三",30));
        System.out.println(map.get(new Student("张三",30)));
        System.out.println(map);
    }
}